<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\Resource;

class UserResource extends Resource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {

        /** @var \App\Models\User $user */
        $user = $this;
        return [
            'id' => $user->id,
            'name' => $user->name,
            'phone' => $user->phone,
            'level' => $user->level,
            'level_label' => $user->levelDetail ? $user->levelDetail->level_name : '会员',
            'parent' => $user->getParent(),
            'money' => $user->money,
            'point' => $user->point,
            'created_at' => $user->created_at->toDateString()
        ];
//        return parent::toArray($request);
    }
}
